package com.springboot.admin.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

@Controller
public class TableController {

  /**
   * @param a 不带请求参数或者参数类型不对 400；Bad Request 一般都是浏览器的参数没有传递正确
   * @return
   */
  @GetMapping("/basic_table")
  public String basic_table(@RequestParam("a") int a) {

    int i = 10 / 0;
    return "table/basic_table";
  }

  @GetMapping("/user/delete/{id}")
  public String deleteUser(
      @PathVariable("id") Long id,
      @RequestParam(value = "pn", defaultValue = "1") Integer pn,
      RedirectAttributes ra) {

    return "redirect:/dynamic_table";
  }

  @GetMapping("/dynamic_table")
  public String dynamic_table(
      @RequestParam(value = "pn", defaultValue = "1") Integer pn, Model model) {


    return "table/dynamic_table";
  }

  @GetMapping("/responsive_table")
  public String responsive_table() {

    return "table/responsive_table";
  }

  @GetMapping("/editable_table")
  public String editable_table() {
    return "table/editable_table";
  }
}
